package cn.pconline.autoclub.util;

import java.util.Date;
import java.util.List;

import cn.pconline.autoclub.entity.Photo;

/**
 * 最新上传辅助工具类
 * TO DO 用于保存某天，某用户上传的图片
 * @author fgs
 *
 */
public class LastestPhoto {

	private Date createDate;
	private long userId;
	private List<Photo> photos;
	
	
	public LastestPhoto(Date createDate, long userId) {
	    super();
	    this.createDate = createDate;
	    this.userId = userId;
    }
	public LastestPhoto(Date createDate, long userId, List<Photo> photos) {
	    super();
	    this.createDate = createDate;
	    this.userId = userId;
	    this.photos = photos;
    }
	public Date getCreateDate() {
    	return createDate;
    }
	public void setCreateDate( Date createDate ) {
    	this.createDate = createDate;
    }
	public long getUserId() {
    	return userId;
    }
	public void setUserId( long userId ) {
    	this.userId = userId;
    }
	public List<Photo> getPhotos() {
    	return photos;
    }
	public void setPhotos( List<Photo> photos ) {
    	this.photos = photos;
    }
	
	public boolean add(Photo p) {
		photos.add(p);
		return true;
    }
	
	public boolean equals(Object o){
		if(this==o){
			return true;
		}
		if(!(o instanceof LastestPhoto)){
			return false;
		}
		LastestPhoto lastestPhoto = (LastestPhoto)o;
		String ymd1 =DateUtils.format(this.getCreateDate());
		String ymd2 = DateUtils.format(lastestPhoto.getCreateDate());
		if(ymd1.equals(ymd2)&&this.getUserId()==lastestPhoto.getUserId()){
			return true;
		}else{
			return false;
		}
	}
	
}
